﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace InputScanner
{
    class Program
    {
        static void Main(string[] args)
        {
            using (StreamWriter file = new StreamWriter("user.out"))
            {
                file.AutoFlush = true;

                string line;

                while ((line = Console.ReadLine()) != null)
   //             System.IO.StreamReader file1 =
   //new System.IO.StreamReader("input.txt");
   //             while ((line = file1.ReadLine()) != null)
                {
                    int[] nums = line.Split(' ').Where(p => p!="").Select(p=> int.Parse(p)).ToArray();

                    int m = nums[0];
                    int n = nums[1];
                    int[,] vec2d = new int[m,n];
                    for (int i = 0; i < m; i++)
                    {
                        for (int j = 0; j < n; j++)
                        {
                            vec2d[i,j] = nums[i*n + j];
                        }
                    }
                    //file.WriteLine(__Serializer__.serialize(new Solution().spiralOrder(vec2d)));
                    printFile(vec2d, m, n, file);
                }
            }
        }

        /*
         * number: 111
         * http://lcoj.tk/library/edit/111/
public class Solution {
    public List<int> spiralOrder(int[][] matrix) {
        
    }
}

class __Driver__ {
  static void Main(string[] args) {
      using (StreamWriter file = new StreamWriter("user.out")) {
          file.AutoFlush = true;

          string line;

          while ((line = Console.ReadLine()) != null) {
              int[] nums = line.Split(' ').Where(p => p!="").Select(p=> int.Parse(p)).ToArray();

              int m = nums[0];
              int n = nums[1];
              int[,] vec2d = new int[m,n];
              for (int i = 0; i < m; i++) {
                  for (int j = 0; j < n; j++) {
                      vec2d[i,j] = nums[i*n + j];
                  }
              }
              file.WriteLine(__Serializer__.serialize(new Solution().spiralOrder(vec2d)));
          }
      }
  }
}
         * */

        static void printFile(int[,] vec2d, int m, int n, StreamWriter file)
        {
            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    file.Write(vec2d[i, j] + "\t");
                }
                file.WriteLine();
            } 
            file.Flush();
        }
    }
}
